package com.kanche.bigbaby.support.base;

import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;

public abstract class BasePage implements OnClickListener {

    protected Context context;
    protected Activity activity;
    protected FragmentActivity fragmentActivity;
    protected View contentView;
    public BasePage(Context context) {
        this.context = context;

        if(context instanceof  Activity){
            this.activity = (Activity)context;
        }
        if(context instanceof  FragmentActivity){
            this.fragmentActivity = (FragmentActivity)context;
        }
        contentView = initView((LayoutInflater) this.context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE));
    }
    Fragment fragment;

    public BasePage(Fragment fragment) {
        this.fragment = fragment;
        this.fragmentActivity = fragment.getActivity();
        this.activity = fragmentActivity;
        this.context = fragmentActivity;
    }

    public View getContentView() {
        return contentView;
    }
    protected abstract View initView(LayoutInflater inflater);

    public <T extends View> T justFindIt(View view,int id ){
        return (T)(view.findViewById(id));
    };

//	public abstract void initData();

}
